﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AFSharedLibrary;
using UIDesigner.SurfaceProperties.Information;

namespace UIDesigner.SurfaceProperties.Operations
{
    public enum ConstructorOptions
    {
        Uninitialized,
        OptionsPanel,
        DefaultConstructor
    }

    public enum CreateButtonOptions
    {
        Uninitialized,
        Button,
        Link
    }

    public class CreateProperties : IPropertyGroup
    {
        [System.Xml.Serialization.XmlIgnore()]
        private ConstructorOptions m_eConstructorOptions;
        [System.Xml.Serialization.XmlIgnore()]
        private CreateButtonOptions m_eCreateButtonOptions;
        [System.Xml.Serialization.XmlIgnore()]
        private List<SurfaceConstructorInfo> m_rgConstructorInfos;
        [System.Xml.Serialization.XmlIgnore()]
        protected CreateOptions m_eObjectCreateOptions;
        [System.Xml.Serialization.XmlIgnore()]
        protected IEventStateValue m_objCreateState;
        [System.Xml.Serialization.XmlIgnore()]
        private string m_strObjectName;
        [System.Xml.Serialization.XmlIgnore()]

        public SurfaceButton Button
        {
            get
            {
                if (m_eObjectCreateOptions == CreateOptions.CreateNewButton)
                {
                    return SurfaceButton.CreateNew;
                }
                else
                {
                    return SurfaceButton.None;
                }
            }
        }

        public string ObjectName
        {
            get { return m_strObjectName; }
            set { m_strObjectName = value; }
        }

        public CreateOptions CreateOptions
        {
            get { return m_eObjectCreateOptions; }
            set { m_eObjectCreateOptions = value; }
        }

        public ConstructorOptions ConstructorOptions
        {
            get { return m_eConstructorOptions; }
            set { m_eConstructorOptions = value; }
        }

        [System.Xml.Serialization.XmlIgnore()]
        public IEventStateValue CreateState
        {
            get
            {
                return m_objCreateState;
            }

            set
            {
                m_objCreateState = value;
            }
        }

        public CreateButtonOptions CreateButtonOptions
        {
            get { return m_eCreateButtonOptions; }
            set { m_eCreateButtonOptions = value; }
        }

        [System.Xml.Serialization.XmlIgnore()]
        public List<SurfaceConstructorInfo> ConstructorInfos
        {
            get 
            {
                if (m_rgConstructorInfos == null)
                {
                    m_rgConstructorInfos = new List<SurfaceConstructorInfo>();
                }

                return m_rgConstructorInfos; 
            }
        }

        public CreateProperties()
        {
        }

        public CreateProperties(ConstructorOptions eConstructorOptions, CreateButtonOptions eCreateButtonOptions)
        {
            m_eConstructorOptions = eConstructorOptions;
            m_eCreateButtonOptions = eCreateButtonOptions; 
        }

        public object Clone()
        {
            CreateProperties objProperties = new CreateProperties(0, 0);

            objProperties.ConstructorOptions = this.m_eConstructorOptions;
            objProperties.CreateButtonOptions = this.CreateButtonOptions;
            objProperties.CreateOptions = this.CreateOptions;
            objProperties.ObjectName = this.ObjectName;

            return objProperties;
        }
    }
}
